package com.ayoka.parenting.ui.coach.applycoachcondition;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.ApplyCoachConditionBean;
import com.ayoka.parenting.databinding.ActivityApplyCoachConditionBinding;
import com.ayoka.parenting.mvp.MVPBaseActivity;
import com.ayoka.parenting.ui.coach.applycoach.ApplyCoachActivity;
import com.ayoka.parenting.ui.coach.invitedrecord.InvitedRecordActivity;
import com.ayoka.parenting.ui.coach.sendinvitecode.SendInviteCodeActivity;
import com.jincp.common.model.ToolBarOptions;

import android.databinding.ViewDataBinding;
import android.view.View;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: ApplyCoachConditionActivity.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class ApplyCoachConditionActivity extends MVPBaseActivity<ActivityApplyCoachConditionBinding, ApplyCoachConditionContract.View, ApplyCoachConditionPresenter> implements ApplyCoachConditionContract.View {


    public static void start(Activity activity) {
        Intent intent = new Intent(activity, ApplyCoachConditionActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected int getContentLayout() {
        return R.layout.activity_apply_coach_condition;
    }

    @Override
    protected void initViews() {
        mDataBinding.btnSendInvite.setOnClickListener(this);
        mDataBinding.btnCheckInviteUser.setOnClickListener(this);
        mDataBinding.btnSubmitApplyTable.setOnClickListener(this);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        ToolBarOptions options = new ToolBarOptions(R.string.apply_haba_coach);
        options.backgroundResource = 0;
        options.navigateId = R.mipmap.icon_back_white;
        options.titleColor = Color.WHITE;
        setCustomToolBar(mDataBinding.customToolbar.toolbar, options);

        if (mPresenter != null) {
            mPresenter.getMyInvitedUserCount();
        }
    }

    @Override
    protected ApplyCoachConditionPresenter getPresenter() {
        return new ApplyCoachConditionPresenter();
    }

    @Override
    public void onClick(View view) {
        if (view == mDataBinding.btnSendInvite) {
            SendInviteCodeActivity.start(this);
        } else if (view == mDataBinding.btnCheckInviteUser) {
            InvitedRecordActivity.start(this);
        } else if (view == mDataBinding.btnSubmitApplyTable) {
            ApplyCoachActivity.start(this);
        }
    }

    @Override
    public void configMyInvitedUserCountData(ApplyCoachConditionBean data) {
        if (data == null) return;
        mDataBinding.btnSubmitApplyTable.setEnabled(data.count >= 3);
    }
}
